Memory control method and related device

ABSTRACT

The present invention provides a memory control method and related device. The method includes storing a bit stream into a memory, reading from the memory a header corresponding to the bit stream, and within a part of a region storing the bit stream, rearranging data stored in the memory according to the header. The rearranging step moves or copies the data in the memory to a part in the region storing the bit stream that has already been read.

BACKGROUND OF INVENTION

1. Field of the Invention

The present invention relates to a memory control method and related device, and more particularly, to a memory control method and circuit capable of enhancing buffering performance.

2. Description of the Prior Art

According to new encoding algorithms, encoded data of a frame may be located in another frame due to considerations of output buffering control and bit rate. For example, according to MPEG audio layer 3 (MP3) frame structure, a frame header of a frame includes MP3 side information within the frame, but encoded data of the frame may be located within the preceding frame. In another example, according to Ogg page structure, which is a developing specification, a page header of a page may introduce a plurality of packets coming after. The last packet of the page may include a portion of packet data packed within the page due to reasons such as buffer size limit and bit rate control. The unpacked portion of the packet data may be further packed as a continued packet next to a page header of the next page. It is a common problem of the above-mentioned algorithms, the MP3 frame structure and the Ogg page structure, that encoded data of the same frame or the same page are divided into two portions because of the header between two adjacent frames or pages. As a result, decoding encoded data that is not arranged continuously is not easy as decoding encoded data that is arranged continuously.

FIG. 1 illustrates a buffering control method for a decoding process according to the prior art, wherein F^(i) denotes an I^(th) frame, F^(i−1) denotes an (I−1)^(th) frame, and so forth. A header H^(i), data D^(i) ₁, D^(i) ₂, and the frame F^(i) stored in a buffering region B11 have the same superscript i, representing that the header H^(i) and the data D^(i) ₁, D^(i) ₂ logically belong to the frame F^(i). Additionally, the subscripts 1, 2 of the data D^(i) ₁, D^(i) ₂ represent two portions 1, 2 of the data D^(i), which includes the data D^(i) ₁, D^(i) ₂, divided by the header H^(i) between the two adjacent frames F^(i), F^(i−1). Regarding to the above-mentioned problem that the encoded data is not arranged continuously, the buffering control method shown in FIG. 1 further allocates another buffering region B12, in contrast to the region B11, for storing a bit stream needing to be decoded. According to the buffering control method shown in FIG. 1, the data D^(i) ₁, D^(i) ₂ are copied to the buffering region B12 to form within the buffering region B12 continuously arranged data D^(i) ₁, D^(i) ₂ for further decoding. As the buffering control method shown in FIG. 1 further allocates the additional buffering region B12, the storage volume requirement of the memory is increased, even if the buffering regions B11, B12 are allocated within the same memory. FIG. 2 illustrates another buffering control method according to the prior art. The buffering control method shown in FIG. 2 parses a data flow read from a disk 205 and respectively store headers H^(i−1), H^(i), . . . and data D^(i−1) ₁, D^(i−1) ₂, D^(i) ₁, D^(i) ₂, . . . in buffering regions B21, B22. Regarding to some embedded systems, it is inconvenient to implement the buffering control method shown in FIG. 2. Both methods of FIG. 1, 2 are imperfect.

SUMMARY OF INVENTION

It is therefore an objective of the present invention to provide a memory control method and a related device to solve the above-mentioned problems.

The present invention provides a memory control method. The memory control method includes storing a bit stream into a memory, reading from the memory a header corresponding to the bit stream, and within a part of a region storing the bit stream, rearranging data stored in the memory according to the header.

The present invention further provides a memory control circuit corresponding to the above-mentioned memory control method. The memory control circuit includes a memory for storing a bit stream, a header parser coupled to the memory for reading from the memory a header corresponding to the bit stream, and a rearrangement unit couple to the memory and the header parser for rearranging data stored in the memory according to the header within a part of a region storing the bit stream.

It is an advantage of the present invention that the memory control method and circuit form continuously arranged data for further decoding in the region storing the bit stream so that, for decoding, it is not necessary to allocate another region in contrast to the region storing the bit stream or to install another memory in addition to the memory for storing the bit stream. As a result, the storage volume of the memory is cost-effective.

These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiments that are illustrated in the various figures and drawings.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is an operational diagram of a buffering control method according to the prior art.

FIG. 2 is an operational diagram of another buffering control method according to the prior art.

FIG. 3 is a flowchart of a memory control method according to the present invention.

FIG. 4 is a diagram of a memory control circuit according to the present invention.

FIG. 5 is an operational diagram of the memory control method shown in FIG. 3 according to a first embodiment of the present invention.

FIG. 6 is an operational diagram of the memory control method shown in FIG. 3 according to a second embodiment of the present invention.

DETAILED DESCRIPTION

Please refer to FIGS. 3, 4, and 5A, which is the first half portion of FIG. 5. FIG. 3 is a flowchart of a memory control method according to the present invention, FIG. 4 is a diagram of a memory control circuit according to the present invention, and FIG. 5A illustrates a buffering region B41 used in the memory control method shown in FIG. 3 according to a first embodiment of the present invention. In FIG. 5A, F^(i) denotes an I^(th) frame, F^(i−1) denotes an (I−1)^(th) frame, and so forth. Similar notations are used for comparing the present invention to the prior art. Within the buffering region B41, the data D^(i−1) ₁, the header H^(i−1), the data D^(i−1) ₂, D^(i) ₁, the header H^(i), the data D^(i) ₂, D^(i+1) ₁, . . . are stored in the same order as that of corresponding data and headers in a bit stream 408 shown in FIG. 4. That is, the contents D^(i−1) ₁, H^(i−1), D^(i−1) ₂, D^(i) ₁, H^(i), D^(i) ₂, D^(i+1) ₁, . . . stored in the buffering region B41 shown in FIG. 5A is the raw information of the bit stream 408 without any processing. Regarding to the above-mentioned raw information, the present invention provides a memory control method capable of enhancing buffering control efficiency. The memory control method is described using the following steps, however, the order of the steps is not a limitation of the present invention.

Step 310: Store a bit stream 408 into a memory 410.

Step 320: Read from the memory 410 a header H^(i) corresponding to the bit stream 408 using a header parser 420.

Step 330: Within a part F^(i) of a region B41 storing the bit stream 408, rearrange the data D^(i) ₂ stored in the memory 410 according to the header H^(i) using a rearrangement unit 430.

Step 340: Decode the data D^(i) ₁, D^(i) ₂ stored in the memory 410 according to the header H^(i) using a decoder 440 to generate a decoded signal 442.

For implementing the rearrangement unit 430 of the present invention, a specific circuit such as a Direct Memory Access (DMA) module or a program executed on a CPU are both applicable. As shown in FIG. 4, the rearrangement unit 430 of this embodiment is a DMA module. According to this embodiment, as the header H^(i) includes explicit or implicit information regarding the location and the length of the data D^(i) ₂ within the frame F^(i), the header parser 420 derives the location and the length of the data D^(i) ₂ after reading the header H^(i) in step 320. In step 330, according to the location and the length of the data D^(i) ₂ outputted by the header parser 420, the rearrangement unit 430 moves or copies the data D^(i) ₂ to the memory region which has already been read, i.e. the region originally storing the header H^(i) shown in FIG. 5A, so that, in the memory 410, the moved or copied data D^(i) ₂ and the data D^(i) ₁ corresponding to the bit stream 408 form continuously arranged data D^(i) ₁, D^(i) ₂. The result of the buffering control mentioned above is shown as the second half portion of FIG. 5, i.e. FIG. 5B. Please note, whether the old data shown having a diagonal pattern in FIG. 5B should be deleted or not while rearranging the data D^(i) ₂ depends on implementation choices of the present invention and is not a limitation of the present invention. As step 330 may copy or move the data D^(i) ₂ starting from the beginning of the data D^(i) ₂ in at least one smaller unit, even if the displacement of the moved or copied data D^(i) ₂ is smaller than the length of the data D^(i) ₂, it does not hinder the implementation of the present invention. The above-mentioned smaller unit can be a combination of smaller units of different sizes, and the smaller units can be a bit, a byte, a plurality of bits, a plurality of bytes, . . . being up to the length of the header H^(i).

The steps 310, 320, 330, 340 of the memory control method performed with respect to the frame F^(i) are applicable for each of the frames F¹, F², . . . , F^(i−1), F^(i), F^(i+1), . . . except for the initial frame F⁰. As mentioned, the header H^(i) includes the explicit or implicit information of the location and the length of the data D^(i) ₂, and similarly, the header H^(i−1) of the frame F^(i−1), which was read previously, includes the explicit or implicit information of the location and the length of the data D^(i) ₁. Therefore, the decoder 440 may decode the continuously arranged data D^(i) ₁, D^(i) ₂ shown in FIG. 5B according to the explicit or implicit information of the locations and the lengths of the data D^(i) ₁, D^(i) ₂, wherein the explicit or implicit information is outputted by the header parser 420. Please note, the data D⁰ of the above-mentioned initial frame F⁰ is a continuously arranged data within the initial frame F⁰, so it is unnecessary to perform step 330 with respect to the initial frame F⁰. Step 340 decodes the data D⁰ stored in the memory 410 according to the header H⁰ using the decoder 440 to generate the decoded signal 442.

Regarding the order of the data D^(i−1) ₁, the header H^(i−1), the data D^(i−1) ₂, D^(i) ₁, the header H^(i), the data D^(i) ₂, D^(i+1) ₁, . . . stored in the buffering region B41 shown in FIG. 5A, the present invention according to the first embodiment illustrated above is suitable for the MP3 specification, the MPEG2 multichannel extension frame specification, the Ogg page structure specification, or their variances. Regardless of whether the bit stream 408 is encoded in accordance with the MP3 specification, the MPEG2 multichannel extension frame specification, the Ogg page structure specification, or another specification, the first embodiment illustrates that the locations of the header H^(i) and the data D^(i) ₂ needing to be moved or copied correspond to the same frame or packet of the bit stream 408 before the rearrangement performed in step 330.

Referring to FIG. 4 and FIG. 5, the present invention further provides a memory control circuit 400 corresponding to the above-mentioned memory control method according to the first embodiment. The memory control circuit 400 includes the memory 410 for storing the bit stream 408, the header parser 420 coupled to the memory 410 for reading from the memory 410 the header H^(i) corresponding to the bit stream 408, and the rearrangement unit 430 couple to the memory 410 and the header parser 420 for rearranging the data D^(i) ₂ stored in the memory 410 according to the header H^(i) within the part F^(i) of the region B41 storing the bit stream 408. The memory control circuit 400 further includes the decoder 440 coupled to the memory 410 and the header parser 420 for decoding the data D^(i) ₁, D^(i) ₂ stored in the memory 410 according to the header H^(i) to generate the decoded signal 442. In this embodiment, the header parser 420 and decoder 440 are installed in an integrated unit, and the rearrangement unit 430 moves or copies the data D^(i) ₂ to the part which is already read in the region B41 storing the bit stream 408 so that, in the memory 410, the moved or copied data D^(i) ₂ and the data D^(i) ₁ corresponding to the bit stream 408 form the continuously arranged data D^(i) ₁, D^(i) ₂ as shown in FIG. 5B. As mentioned, regardless of whether the bit stream 408 is encoded in accordance with the MP3 specification, the MPEG2 multichannel extension frame specification, the Ogg page structure specification, or another specification, the first embodiment illustrates that the locations of the header H^(i) and the data D^(i) ₂ needing to be moved or copied correspond to the same frame or packet of the bit stream 408 before the rearrangement performed by the rearrangement unit 430.

A second embodiment shown in FIG. 6 is similar to the first embodiment shown in FIG. 5 with the exceptions described in the following paragraphs. According to the second embodiment, the description of step 330 is revised as follows:

Step 330′: Within a part F^(i−1), F^(i) of a region B41 storing the bit stream 408, rearrange the data D^(i) ₁ stored in the memory 410 according to the header H^(i) using the rearrangement unit 430.

As the header H^(i) includes explicit or implicit information of the location and the length of the data D^(i) ₂ within the frame F^(i), the header parser 420 derives the location and the length of the data D^(i) ₂ after reading the header H^(i) in step 320. The steps 310, 320, 330′, 340 of the memory control method performed with respect to the frame F^(i) are applicable for each of the frames F¹, F², . . . , F^(i−1), F^(i), F^(i+1), . . . . Therefore, in step 330′, according to the locations and the lengths of the data D^(i) ₁, D^(i) ₂ outputted by the header parser 420, the rearrangement unit 430 moves or copies the data D^(i) ₁ to the memory region which has already been read, i.e. the region originally storing the header H^(i) shown in FIG. 6A, so that, in the memory 410, the moved or copied data D^(i) ₁ and the data D^(i) ₂ corresponding to the bit stream 408 forms continuously arranged data D^(i) ₁, D^(i) ₂. The result of the buffering control mentioned above is shown as FIG. 6B. Please note, whether the old data shown having diagonal pattern in FIG. 6B should be deleted or not while rearranging the data D^(i) ₁ depends on implementation choices of the present invention and is not a limitation of the present invention. As mentioned, the header H^(i) includes the explicit or implicit information of the location and the length of the data D^(i) ₂. The header H^(i−1) of the frame F^(i−1), which has been previously read, includes the explicit or implicit information of the location and the length of the data D^(i) ₁. Therefore, the decoder 440 may decode the continuously arranged data D^(i) ₁, D^(i) ₂ shown in FIG. 6B according to the explicit or implicit information of the locations and the lengths of the data D^(i) ₁, D^(i) ₂, wherein the explicit or implicit information is outputted by the header parser 420. Regarding the new location of the data D^(i) ₁ shown in FIG. 6B, the data D^(i) ₁ is located prior to the data D^(i) ₂ with the end of the data D^(i) ₁ adjacent to the beginning of the data D^(i) ₂, and the displacement from the beginning of the data D^(i) ₂ to the beginning of the data D^(i) ₁ is equal to the length of the data D^(i) ₁. As step 330′ may copy or move the data D^(i) ₁ starting from the end of the data D^(i) ₁ in at least one smaller unit, even if the displacement is greater than the length of the header H^(i), it does not hinder the implementation of the present invention. The above-mentioned smaller unit can be a combination of smaller units of different sizes, and the smaller units can be a bit, a byte, a plurality of bits, a plurality of bytes, . . . being up to the length of the header H^(i). Additionally, according to the second embodiment, the decoder 440 calculates the displacement. This is an implementation choice of the present invention. In another embodiment of the present invention, the header parser 420 may calculate the displacement and then output the displacement into the decoder 440.

Regarding the order of the data D^(i−1) ₁, the header H^(i−1), the data D^(i−1) ₂, D^(i) ₁, the header H^(i), the data D^(i) ₂, D^(i+1) ₁, . . . stored in the buffering region B41 shown in FIG. 6A, the present invention according to the second embodiment illustrated above is suitable for the MP3 specification, the MPEG2 multichannel extension frame specification, the Ogg page structure specification, or their variances. Regardless of whether the bit stream 408 is encoded in accordance with the MP3 specification, the MPEG2 multichannel extension frame specification, the Ogg page structure specification, or other specifications, the second embodiment illustrates that the locations of the header H^(i) and the data D^(i) ₂ needing to be moved or copied respectively correspond to two adjacent frames or packets of the bit stream 408 before the rearrangement of step 330′.

As mentioned in the first embodiment and the second embodiment, the header H^(i) includes the explicit or implicit information of the location and the length of the data D^(i) ₂, and the header H^(i−1) of the frame F^(i−1) includes the explicit or implicit information of the location and the length of the data D^(i) ₁. This is an implementation choice of the present invention. While applying different encoding specifications using the present invention, the above-mentioned description corresponding to the implementation choice may vary. In another embodiment of the present invention, the header H^(i−1) includes the explicit or implicit information of the location and the length of the data D^(i) ₂ within the frame F^(i). In another embodiment of the present invention, the header H^(i) includes the explicit or implicit information of the location and the length of the data D^(i) ₁ within the frame F^(i). Please note, the above-mentioned explicit information refers to the information directly recoded in the headers, and the above-mentioned implicit information refers to the information being values, codes, indexes, etc. having implicit meanings and recoded in the headers. The above-mentioned implicit information of the location and the length can be derived from lookup tables or calculations.

In contrast to the prior art, the memory control method and circuit form continuously arranged data for further decoding in the region storing the bit stream so that, for decoding, it is not necessary to allocate another region in contrast to the region storing the bit stream or to install another memory in addition to the memory for storing the bit stream. As a result, the storage volume of the memory is cost-effective.

Those skilled in the art will readily observe that numerous modifications and alterations of the device may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims. 

1. A memory control method, the memory control method comprising: (a) storing a bit stream into a memory; (b) reading from the memory a header corresponding to the bit stream; and (c) within a part of a region storing the bit stream, rearranging data stored in the memory according to the header by moving or copying the data to a part in the region storing the bit stream that has already been read; wherein the data is a second data corresponding to the bit stream; and step (c) moves or copies the second data to the part that has already been read so that, in the memory, the moved or copied second data and a first data corresponding to the bit stream form continuously arranged data.
 2. The memory control method of claim 1, wherein before the rearrangement performed in step (c), locations of the header and the data needing to be moved or copied correspond to the same frame or packet of the bit stream.
 3. The memory control method of claim 1, wherein before the rearrangement of step (c), locations of the header and the data needing to be moved or copied respectively correspond to two adjacent frames or packets of the bit stream.
 4. The memory control method of claim 1, wherein the bit stream is encoded in accordance with the MPEG2 multichannel extension frame specification, the MPEG audio layer 3 (MP3) specification, or the Ogg page structure specification.
 5. The memory control method of claim 1, further comprising: decoding data stored in the memory according to the header.
 6. A memory control circuit, the memory control circuit comprising: a memory for storing a bit stream; a header parser coupled to the memory for reading from the memory a header corresponding to the bit stream; and a rearrangement unit coupled to the memory and the header parser for rearranging data within a part of a region storing the bit stream in the memory according to the header by moving or copying the data to a part in the region storing the bit stream that has already been read; wherein the data is a second data corresponding to the bit stream; and the rearrangement unit moves or copies the second data to the part that has already been read so that, in the memory, the moved or copied second data and a first data corresponding to the bit stream form continuously arranged data.
 7. The memory control circuit of claim 6, wherein before the rearrangement performed by the rearrangement unit, locations of the header and the data needing to be moved or copied correspond to the same frame or packet of the bit stream.
 8. The memory control circuit of claim 6, wherein before the rearrangement performed by the rearrangement unit, locations of the header and the data needing to be moved or copied respectively correspond to two adjacent frames or packets of the bit stream.
 9. The memory control circuit of claim 6, wherein the bit stream is encoded in accordance with the MPEG2 multichannel extension frame specification, the MPEG audio layer 3 (MP3) specification, or the Ogg page structure specification.
 10. The memory control circuit of claim 6, further comprising: a decoder coupled to the memory and the header parser for decoding data stored in the memory according to the header.
 11. The memory control circuit of claim 10, wherein the header parser and the decoder are installed in an integrated unit.
 12. The memory control circuit of claim 6, wherein the rearrangement unit is a Direct Memory Access (DMA) module. 